<?php
header("Content-Type: text/html;charset=utf-8"); 
require_once ('../Config/conn.php"');
require_once ('../Core/filter.php"');

  //htmlspecialchars进行过滤，注意上面filter.php文件是引用过滤问
  $title = htmlspecialchars(isset($_POST['title']) ? $_POST['title'] : '',ENT_QUOTES);
  $content = htmlspecialchars(isset($_POST['content']) ? $_POST['content'] : '',ENT_QUOTES);
  $author = 'admin';
  $time = time();
  $hot = '100';
  $summary =htmlspecialchars(isset($_POST['content']) ? $_POST['content'] : '');



 if($title == '' || $content == ''){
	    echo '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover,{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:(</h1><p>你还没有填写内容！';
	  echo '<script>setTimeout(\'location="index.php"\', 3000);</script>';
	 exit;
	 
	 }else{
		 
     $datas = $db->insert("article",  array(
		  "title" => $title,
		  "content" => $content,
		  "author" => $author,
		  "time" => $time,
		  "hot" => $hot,
		  "summary" => $summary
      ));

		echo '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover,{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>发布成功！';
		echo '<script>setTimeout(\'location="index.php"\', 3000);</script>';
		
	  exit;
		 }
?>